<template>
  <div>
    <el-table v-loading="loading" :data="infoList" border header-cell-class-name="bg-F4F8FF">
      <!-- <el-table-column type="index" width="55" align="center"  label="序号"/> -->
      <el-table-column label="类型" align="center">
        <template slot-scope="scope">
          公共场所卫生检测报告
        </template>
      </el-table-column>
      <el-table-column label="到期状态" align="center" prop="deadlineStatus"/>
      <el-table-column label="到期时间" align="center" prop="deadline" />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getCheckReportDeadlineList,getCheckReportAdd } from '@/api/zhangping/publicPlace'
export default {
  name: 'jcbgTable',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 列表
      infoList: [],
      // 查询参数
      queryParams: {
        pageNum:1,
        pageSize:10,
      },
      visible:false,
      // 表单参数
      addForm:{
        organization:'',
        checkTime:'',
        report:'',
      },
      addRules:{
        organization:[{
          required: true, message: "机构名称不能为空", trigger: "blur"
        }],
        checkTime:[{
          required: true, message: "检测时间不能为空", trigger: "change"
        }],
        report:[{
          required: true, message: "检测报告不能为空", trigger: "change"
        }]
      },
    };
  },
  created() {
    this.loading = false
    this.getList();
  },

  methods :{
    getList(){
      getCheckReportDeadlineList({
        ...this.queryParams,
        creditCode:'229397350881813143'
      }).then(res=>{
        this.total = res.total
        this.infoList = res.rows
      })
    },
    handleInfo(row) {
      this.visible = true
    },
    save(){
      this.$refs.addForm.validate(valid => {
        if(valid){
          if(this.addForm.id){
            getCheckReportResubmit({
              id:this.addForm.id,
              report:this.addForm.report,
              creditCode:'229397350881813143'
            }).then(res=>{
              if(res.code==200){
                this.$message.success('提交成功')
                this.getList()
                this.visible = false
              }
            })
          }else{
            getCheckReportAdd({
              ...this.addForm,
              creditCode:'229397350881813143'
            }).then(res=>{
              if(res.code==200){
                this.$message.success('添加成功')
                this.getList()
                this.visible = false
              }
            })
          }
        }
      })
    },
  }

}
</script>

<style>

</style>
